package cq.zhcqk.util;

import android.webkit.WebView;

import org.apache.http.util.EncodingUtils;

import java.util.HashMap;
import java.util.Map;

import cq.zhcqk.util.x5.X5WebView;

/**
 * Created by zhangle on 2018/1/23.
 */
public class WebViewHeader {

    private static String headerKey1 = "from";
    private static String headerVal1 = "android";

    public static void setHeaderAndLoad(WebView webView,String url){
        Map<String, String > header = new HashMap<>();
        header.put(headerKey1,headerVal1);
        webView.loadUrl(url,header);
    }

    public static void setHeaderAndLoadX5(X5WebView webView, String url){
        Map<String, String > header = new HashMap<>();
        header.put(headerKey1,headerVal1);
        webView.loadUrl(url,header);
    }

    public static void setHeaderTokenAndLoadX5(X5WebView webView, String url,String token){
        Map<String, String > header = new HashMap<>();
        if(!StringUtil.isNull(token)){
            header.put("tk",token);
        }
        header.put(headerKey1,headerVal1);
        webView.loadUrl(url,header);
//        webView.postUrl(url, null);
    }

}
